package com.client.koshercook.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/** use this class to create a panel with round edges, wrapping a widget */
public class EdgesPanel extends Composite{
	
	private VerticalPanel VPanel = new VerticalPanel();
	private HorizontalPanel HPanelTop = new HorizontalPanel();
	private HorizontalPanel HPanelMid = new HorizontalPanel();
	private HorizontalPanel HPanelBottom = new HorizontalPanel();
	
	private Image topLeft = new Image("edgeTopLeft.png");
	private Image TopRight = new Image("edgeTopRight.png");
	private Image BottomLeft = new Image("edgeBottomLeft.png");
	private Image BottomRight = new Image("edgeBottomRight.png");
	
	private HorizontalPanel spacerTop = new HorizontalPanel();
	private HorizontalPanel spacerBottom = new HorizontalPanel();
	
	public EdgesPanel(Widget w){
		
		HPanelMid.add(w);
		HPanelMid.setStyleName("midPanel");
		HPanelMid.setWidth("100%");
		
		VPanel.add(HPanelTop);
		VPanel.add(HPanelMid);
		VPanel.add(HPanelBottom);		
		
		HPanelTop.setWidth("100%");
		HPanelBottom.setWidth("100%");
		
		HPanelTop.add(topLeft);
		HPanelTop.add(spacerTop);
		HPanelTop.add(TopRight);
		
		HPanelTop.setCellHorizontalAlignment(topLeft, HasHorizontalAlignment.ALIGN_LEFT);
		HPanelTop.setCellHorizontalAlignment(TopRight, HasHorizontalAlignment.ALIGN_RIGHT);
		HPanelTop.setCellWidth(topLeft, "10px");
		HPanelTop.setCellWidth(TopRight, "10px");
		
		HPanelBottom.add(BottomLeft);
		HPanelBottom.add(spacerBottom);
		HPanelBottom.add(BottomRight);
		
		HPanelBottom.setCellHorizontalAlignment(BottomLeft, HasHorizontalAlignment.ALIGN_LEFT);
		HPanelBottom.setCellHorizontalAlignment(BottomRight, HasHorizontalAlignment.ALIGN_RIGHT);
		HPanelBottom.setCellWidth(BottomLeft, "10px");
		HPanelBottom.setCellWidth(BottomRight, "10px");
		
		spacerTop.add(new Image("spacer.gif"));
		spacerBottom.add(new Image("spacer.gif"));
		
		spacerTop.setStyleName("midPanel");
		spacerBottom.setStyleName("midPanel");
		spacerTop.setWidth("100%");
		spacerBottom.setWidth("100%");
				
		VPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		
		initWidget(VPanel);
	}
}